package com.jjh.controller;

import com.jjh.consts.Result;
import com.jjh.pojo.Flavour;
import com.jjh.service.FlavourService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/flavour")
public class FlavourController {

    @Resource
    private FlavourService flavourService;


    @GetMapping
    public Result getFlavour(){
        return flavourService.getAll();
    }
    @PostMapping("/add")
    public Result addFlavour(@RequestBody Flavour flavour){
        return  flavourService.addOne(flavour);
    }
    @PutMapping("/update")
    public Result updateFlavour(@RequestBody Flavour flavour){
        return flavourService.updateOne(flavour);
    }

    @PostMapping("/delete")
    public Result deleteUsers(@RequestBody Map<String, List<Integer>> map){
        List<Integer> ids = map.get("ids");
        return flavourService.deleteByIds(ids);
    }




}
